perm filename INTRO.PUB[JC,MUS] blob sn#170871 filedate 1975-07-29 generic text, type C, neo UTF8
COMMENT ⊗   VALID 00003 PAGES
C REC  PAGE   DESCRIPTION
C00001 00001
C00002 00002	.DEVICE XGP
C00003 00003	.BEGIN CENTER
C00014 ENDMK
C⊗;
.DEVICE XGP
.SPACING 10*5 MILLS;
.FONT 1 "BASL30"
.FONT 2 "BASI30"
.FONT 3 "BASB30"
.FONT 4 "BDR40"
.FONT 5 "FIX25"
.FONT 6 "BDI25"

.TURN ON "≡" FOR "%";
.PAGE FRAME 44 HIGH 78 WIDE
.TITLE AREA HEADING LINES 1 TO 2
.AREA TEXT LINES 3 TO 44
.PLACE HEADING
.SELECT 1
.PLACE TEXT
.NOJUST
.NOFILL
.SELECT 1
.NEXT PAGE
.TABS 9,17,25,33,41,49,57,65,73,81,89;
.AT "	" ⊂}\{⊃;
.TURN ON "\{}";
.BEGIN CENTER
≡4A TUTORIAL INTRO TO THE MUSIC PROGRAM≡1
.END
.BEGIN FILL ADJUST
MUS10 is a program which is used to generate a numerical representaion
of a sound-pressure wave.  The input to the program, supplied  by the user,
specifies in physical terms (eg. amplitude, frequency, spectrum)
the nature of the sound wave to be generated.  The output of the program is a
list of numbers, called samples, which are passed sequentially to a
digital-to-analog converter (DAC) which produces a signal
that is converted to a pressure-wave by means of a loudspeaker.  The power
of such a program is in the precision with which the pressure-wave can be
specified, while the labor for the user is to determine what constitutes
an effective specification.


SAMPLING AND QUANTIZING

In order to quickly arrive at a point where you can use MUS10 we will
begin with an informal overview of the sampling process and leave a
more rigorous examination of sampling and related problems until later.
An excellent overview exists in Mathews' book `The Technology of Computer
Music':

	INSERT

In order to specify the rapid changes of pressure in the wave of musical
sounds we must generate with the computer a large number of samples
in order to accurately represent the amplitude of the pressure wave
at successive instants in time.  In this tutorial we will use the
number 10000 samples/sec = sampling rate (SR).

.PAGE FRAME 44 HIGH 88 WIDE;
.NEXT PAGE
.SELECT 2

A SIMPLE REPRESENTATION OF A COMPUTER OSCILATOR≡1

.SELECT 5

 20| 20| 20| 20| 20| 20 .....20| 20|-20|-20|-20|-20|-20|-20 .....-20|-20|
 ↑   ↑   ↑   ↑   ↑   ↑       ↑   ↑   ↑   ↑   ↑   ↑   ↑   ↑        ↑   ↑
 1   2   3   4   5   6      249 250 251 252 253 254 255 256      499 500
.SELECT 1


1    Take contents from 1st location of table
2    Send to DAC
3    Take contents from next location of table
4    Go to Step 2

We can see that  these four instructions will get us through the table
until the condition arises where there is no next location, that is,
when we arrive at location 500.  What we would like, however, is to go
back to the beginning of the table and repeat the process until we have
sent 10000 samples to the DAC (10000 samples represents one second of sound,
remember??).  We can make the following change in our directions, then:

1    Take contents from 1st location of table
2    Send to DAC
2.5  If the next location is greater than 500, Go to step 1, otherwise continue
3    Take contents from next location of table
4    Go to Step 2

Our directions now allow us to go through the table many times, in fact, the
obvious problem is that we must now stop the process after 10000 samples
have been sent to the DAC.  A solution might be:

0    Counter is set to 0
1    Take contents from 1st location of table
2    Send to DAC
2.2  Add 1 to Counter: if Counter is greater than 10000 Go to step 5, otherwise cont
2.5  If the next location is greater than 500, Go to step 1, otherwise continue
3.   Take contents from next location of table
4.   Go to Step 2
5.   STOP

Now, after having generated 10000 samples the process is stopped.  We will
have gone through the table 20 times (10000/500) and generated 20 periods
of the wave or a frequency of 20Hz.

We have now a perfectly acceptable "single frequency and amplitude oscilator".
What can we do if we want to produce a frequency of 40Hz at a different amplitude?

In regard to frequency our choices are either to change the sampling rate
or change the length of the table.
That is, we could run the DAC at 20000 samples/sec and STOP (go to 5) when
counter is greater than 20000; or, we can store the wave in a table which is
only 250 locations which would produce a frequency of 40Hz (10000/250=40).

Our choice will be to shorten the length of the table, but
in a somewhat special way.  The reasons that we choose not to change the sampling
rate will become clear later.

Now, rather than producing a wave table of 250 locations, we can have the
same effect by taking from every other location of the existing table of
500 locations.  That is, if we take the contents from the ≡3first≡1 location
and then skip the second and take next from the ≡3third≡1 location etc., then
in 250 steps we will have gone once through the table.  In the case of
20 Hz we stepped through the table by one while for 40 Hz we must step by
two.

.SELECT 5
 20| 20| 20| 20| 20| 20 .....20| 20|-20|-20|-20|-20|-20|-20 .....-20|-20|
 ↑       ↑       ↑           ↑       ↑       ↑       ↑            ↑
 1   2   3   4   5   6      249 250 251 252 253 254 255 256      499 500
.SELECT 1


If we want to generate a frequency of 80 Hz we need to step through the
table by four, where we take the first location, skip three, take the fifth
location, skip three, etc. where in 125 steps we will have gone through the
table and      10000/125=80 Hz!!!

.SELECT 5
 20| 20| 20| 20| 20| 20 .....20| 20|-20|-20|-20|-20|-20|-20 .....-20|-20|
 ↑               ↑                   ↑               ↑             
 1   2   3   4   5   6      249 250 251 252 253 254 255 256      499 500
.SELECT 1

Perhaps you are beginning to see that there is a direct relationship between
frequency and step size when the sampling rate and table length are constant.
That is, each time we doubled the step size we also doubled the frequency.

Before we adjust our list of directions to accomodate changing frequency
according to step size (although only octaves thus far), we are going to
assign some different names to some of the terms we have been talking
about.  Because of "computer world" conventions we will call our ≡3table≡1
an ≡3ARRAY≡1 and ≡3step size≡1 an ≡3INCREMENT≡1.  That is we generated
frequencies of 20, 40, and 80 Hz by stepping through the ≡3array≡1 (table)
with an ≡3increment≡1 (step size) of first 1, then 2, and then 4.

Our directions

0    Counter is set to 0
1    Array pointer is set 1
2    Take contents from location of array (table) indicated by Array pointer
3    Send to DAC
4    Add 1 to Counter: if Counter is greater than 10000 Go to step 8, otherwise cont
5    Add increment (step size) to Array pointer
6    If Array pointer is greater than 500 subtract out 500
7    Go to Step 2
8    STOP